//
//  SCNBorrowModels.swift
//  ShoucainuSwift
//
//  Created by 王家旭 on 2017/5/15.
//  Copyright © 2017年 Riluee. All rights reserved.
//

import Foundation
import ObjectMapper

class SCNBorrowViewModel: NSObject {
    
    func requestOtherGetIndex(_ block:@escaping ((_ dataresult: SCNBorrowResultModel) -> Void)) -> Void {
        
        SCNRequestManager.postRequest([:], URL: SCNRequestAPI.other().getIndex) { (response) in
            
            let announcementModels = Mapper<SCNBorrowModels>().map(JSONObject: response.result.value)
            
            if let tmp = announcementModels?.dataresult {
                block(tmp)
            }
        }
        
        
    }
}

class SCNBorrowModels: Mappable {
    var dataresult: SCNBorrowResultModel?
    var errmsg: String?
    var status: Int?
    var servertime: Int?
   
    
    init(){}
    
    required init?(map: Map) {
        mapping(map:map)
    }
    
    func mapping(map: Map) {
        
        dataresult <- map["dataresult"]
        errmsg <- map["errmsg"]
        status <- map["status"]
        servertime <- map["servertime"]
    }
    
}
// dataresult
class SCNBorrowResultModel: Mappable {
   
    var borrowtime: [SCNBorrowTimeModel]?
    var types: [SCNBorrowTypesModel]?
  
    init(){}
    
    required init?(map: Map) {
        mapping(map:map)
    }
    
    func mapping(map: Map) {
        
        borrowtime <- map["borrowtime"]
        types <- map["types"]

    }
}
// 贷款期限
class SCNBorrowTimeModel: Mappable {
    var key: Int?
    var name: String?
    
    init(){}
    
    required init?(map: Map) {
        mapping(map:map)
    }
    
    func mapping(map: Map) {
        
        key <- map["key"]
        name <- map["name"]
        
    }
}
// 贷款类型
class SCNBorrowTypesModel: Mappable {
    var id: Int?
    var img: String?
    var name: String?
    var url: String?
    
    
    init(){}
    
    required init?(map: Map) {
        mapping(map:map)
    }
    
    func mapping(map: Map) {
        
        id <- map["id"]
        img <- map["img"]
        name <- map["name"]
        url <- map["url"]
        
    }
}
